import axios from "axios"

// axios.defaults.baseURL = "http://localhost:3000/api"
// axios.defaults.headers.myname = "offcn"


const instance = axios.create({
  baseURL:"http://localhost:3000/",
  headers:{ }

})

 instance.interceptors.request.use(function (request){
     console.log(request,"请求拦截器");
     let uinfo = localStorage.getItem("token")||'{}'
     request.headers.authorization=uinfo;
     return request;
 })

instance.interceptors.response.use(function (response){
    console.log("响应拦截器",response);
    if(response.code==403){
        window.location.href="#/login"
    }
    return response.data;
})

export default instance